import axios from "axios";
import {message} from "antd";
const atguiguRequest = axios.create({
    baseURL:"/api",
    timeout:2000,
})
//请求拦截器
atguiguRequest.interceptors.request.use((config:any)=>{
    if(localStorage.getItem("token")){
        config.headers.token = localStorage.getItem("token")
    }
    return config
})
//响应拦截器
atguiguRequest.interceptors.response.use(({data})=>{
    if(data.code === 200){
        return data.data
    }
    message.error(data.message)
    return  Promise.reject(data)
})
export default atguiguRequest
